<?php

namespace App\Kuafu\Common\Controller\Applet;

use App\Exceptions\CustomValidateException;
use App\Kuafu\Base\Controller\BaseController;
use App\Kuafu\Common\Service\CommonService;
use App\Kuafu\Common\Service\SeparateService;
use App\Kuafu\Common\Validate\CommonValidate;
use App\Kuafu\Config\Model\ConfigModel;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;

class CommonController extends BaseController
{
    /**
     * @param Request $request
     * @return JsonResponse
     * @throws CustomValidateException
     * @throws ContainerExceptionInterface
     * @throws NotFoundExceptionInterface
     */
    public function getImageBySceneKey(Request $request): JsonResponse
    {
        return $this->success(CommonService::getImageBySceneKey(CommonValidate::getImageBySceneKeyValidate($request->all())));
    }

    /**
     * 获取隔断日期
     * @param Request $request
     * @return JsonResponse
     */
    public function getSeparateTime(Request $request)
    {
        return $this->success(['t' => date('Y-m-d H:i:s', SeparateService::getSeparateTime())]);
    }
}
